<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选项卡</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        #container {
            width: 400px;
            margin: auto;
            margin-top: 50px;
        }
        .clear {
            clear: both;
        }
        .option {
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            font-weight: 800;
            font-size: 20px;
            float: left;
        }
        .content {
            width: 400px;
            height: 200px;
            padding-top: 40px;
            float: left;
            display: none;
        }
        p {
            margin-left: 10px;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <div id="container">
        <div id="top">
            <div class="option" style="background: skyblue;">要闻</div>
            <div class="option" style="background: thistle;">娱乐</div>
            <div class="option" style="background: tomato;">体育</div>
            <div class="option" style="background: yellow;">财经</div>
            <div class="clear"></div>
        </div>    
        <div id="bottom">
            <div class="content" style="background: skyblue; display: block">
                <p>国家邮政局：严防境外疫情通过寄递渠道输入</p>
                <p>春节回家哪些东西不能带上火车？这份指南请收好</p>
                <p>让希望的阳光照亮人类 从数据看全面从严治党一严到底</p>
                <p>高质量发展要靠创新 回顾2021 全面从严治党一严到底</p>
            </div>
            <div class="content" style="background: thistle;">
                <p>多位港星内地行善</p>
                <p>2021年香港电影评论学会大奖出炉</p>
                <p>梁朝伟海报与王一博齐亮相</p>
                <p>张靓颖为何能陪伴我们一整个青春？</p>
            </div>
            <div class="content" style="background: tomato;">
                <p>詹皇25+7+7威少制胜2+1 湖人力克爵士终结3连败</p>
                <p>兄弟篮球玩不下去了？哈登真的会离开篮网吗</p>
                <p>知名作家余华：梅西拿那么多金球，应分一两个给C罗</p>
                <p>绝杀不成反遭绝杀！伊布见证疯狂3分钟，队史级耻辱就此诞生</p>
            </div>
            <div class="content" style="background: yellow;">
                <p>央行副行长谈人民币汇率</p>
                <p>央行：LPR会及时充分反映市场利率变化 引导企业贷款利率下行</p>
                <p>发改委：猪粮比价进入过度下跌三级预警区间</p>
                <p>港股震荡 电力股大涨丨港股收市</p>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <script>
        var options = document.getElementsByClassName("option");
        var contents = document.getElementsByClassName("content");
        for (var i = 0; i < options.length; i++) {
            options[i].index = i;
            options[i].onclick = function() {
                for (var j = 0; j < contents.length; j++) {
                    contents[j].style.display = "none";
                }
                contents[this.index].style.display = "block";
            }
        }
    </script>
</body>
</html>